<template>
  <el-container>
    <el-header>
      <div class="header">
        <div class="header-left">
          <span v-if="!isFold">锋迷酒店管理系统</span>
          <span v-else class="iconfont icon-jiudian1 jiudian"></span>
          <b :class="foldIcon" @click="changeFold"></b>
        </div>
        <div class="header-right" >
            <el-tooltip class="item" effect="dark" content="Hi!admin" placement="left-end" >
                <span class="adminlogo" @click="isShow = !isShow">
                    <img src="adminLog.jpg">
                </span>
            </el-tooltip>
            <transition name="el-zoom-in-top">
              <div v-show="isShow" class="transition-box">
                <ul>
                  <li>个人中心</li>
                  <li>系统维护</li>
                  <li @click="loginClick">退出登录</li>
                </ul>
              </div>
            </transition>
        </div>
      </div>
    </el-header>
    <el-container>
      <el-aside :width="`${asideWidth}px`">
        <el-menu
          :default-active="defaultpath"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          style="border:0;"
          :collapse="isFold"
          router>
          <el-menu-item index="/home">
            <i class="el-icon-s-platform"></i>
            <span slot="title">控制台</span>
          </el-menu-item>
		  <el-menu-item index="/homes">
		    <i class="el-icon-s-platform"></i>
		    <span slot="title">房间管理</span>
		  </el-menu-item>
		  
		  <el-menu-item index="/comment">
		    <i class="el-icon-s-platform"></i>
		    <span slot="title">评论管理</span>
		  </el-menu-item> 
		  <el-menu-item index="/employee/staff">
		    <i class="el-icon-s-platform"></i>
		    <span slot="title">员工管理</span>
		  </el-menu-item> 
			<el-menu-item index="/parking/manage">
			  <i class="el-icon-s-platform"></i>
			  <span slot="title">停车位管理</span>
			</el-menu-item> 
         </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data(){
    return {
      foldIcon : 'el-icon-s-fold',
      isFold:false,
      asideWidth:200,
      defaultpath:location.pathname,
      isShow:false
    }
  },
  created(){

  }, 
  methods:{
    changeFold() {
      this.isFold = !this.isFold;
      this.foldIcon = this.isFold ? 'el-icon-s-unfold' : 'el-icon-s-fold';
      this.asideWidth = this.isFold ? 65 : 200
    },
    //退出登录
    loginClick () {
      //清空token
      window.sessionStorage.clear();
       this.$router.push('/login')
    }
  }
}
</script>

<style scoped>
  .el-header,.el-aside{
    background-color: #545c64;
    color: #f1f4f78c;
    transition: all 0.3s;
  }
  .el-container{
    height: 100%;
  }
  .el-main{
    height: 100%;
  }
  .jiudian{
    color: rgb(0, 255, 200);
  }
  .header{
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    padding:5px  0;
  }
  .header-left span{
    font-size: 20px;
    margin-right: 20px;
  }
  .header-left span:nth-child(1){
    font-weight: bold;
    user-select: none;
    cursor: default;
  }
  .header-left b{
    cursor: pointer;
    font-weight: no;
  }
  .header-right{
    width: 50px;
    height: 50px;
    margin: 0 20px;
    cursor: pointer;
    position: relative;
  }
  .header-right span:first{
    display: block;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid;
    background-color: orange;
    margin-right: 30px;
    cursor: pointer;
  }
  .adminlogo img{
    width: 50px;
    height: 50px;
    border-radius: 50%;
  }
  .header-right span:nth-child(2){
    cursor: pointer;
  }
  .transition-box {
    position: absolute;
    left: -23px;
    width: 100px;
    height: 140px;
    border-radius: 4px;
    background-color: #409EFF;
    color: #fff;
    box-sizing: border-box;
  }
  .transition-box ul {
    width: 100%;
    height: 100%;
    list-style: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    padding-left: 0;
  }
  .transition-box ul li{
    width: 100%;
    height: 30%;
    text-align: center;
    padding-top: 14px;
  }
  .el-main{
    height: 100%;
  }
</style>